package com.lanou.renrenxin.custommodule;

import android.app.DialogFragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import com.easemob.chat.EMMessage;
import com.lanou.renrenxin.R;
import com.lanou.renrenxin.onclicklistener.DialogClickListener;
import com.lanou.renrenxin.tools.StringValues;

/**
 * Created by zouhui on 16/3/15.
 */
public class LongClickDialog extends DialogFragment implements View.OnClickListener {
    private DialogClickListener dialogClickListener;
    private EMMessage emMessage;

    public void setDialogClickListener(DialogClickListener dialogClickListener) {
        this.dialogClickListener = dialogClickListener;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = inflater.inflate(R.layout.dialog_longclick, container, false);
        view.findViewById(R.id.btn_dialog_longclick_copy).setOnClickListener(this);
        view.findViewById(R.id.btn_dialog_longclick_forward).setOnClickListener(this);
        view.findViewById(R.id.btn_dialog_longclick_delete).setOnClickListener(this);
        Bundle bundle = getArguments();
        emMessage = bundle.getParcelable(StringValues.DIALOG_EMMESSAGE);
        return view;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_dialog_longclick_copy:
                dialogClickListener.copyMsg();
                break;
            case R.id.btn_dialog_longclick_delete:
                dialogClickListener.deleteMsg();
                break;
            case R.id.btn_dialog_longclick_forward:
                dialogClickListener.forwardMsg(emMessage);
                break;
        }
    }
}
